<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .list{
            width: 400px;
            height: 200px;
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            margin: auto;
            text-align: center;
        }

        .wrap{
            display: flex;
        }
        .wrap span{
            flex: 1;
            border: 1px solid;
        }
        .wrap button{
            flex: 1;
            margin: 0 5px;
        }
    </style>
</head>
<body>
    <div id="app">
        <ul class="list">
            <li class="wrap" v-for="(val,key,index) in obj" :key="index">
                <span>{{index}}:</span>
                <span>{{key}}</span>
                <span>{{val}}</span>
            </li>
        </ul>
        <button @click="delFn">del</button>
        <button @click="addFn">add</button>
        <button @click="updateFn">update</button>
    </div>
</body>
<script src="./js/vue.js"></script>
<script>
    Vue.config.productionTip = false;

    new Vue({
        el:"#app",
        data:{
            obj:{
                name:"达姆",
                age:18,
                wife:"冬雨"
            }
        },
        methods:{
            delFn(){
                //触发不了响应式
                // delete this.obj.age
                // Vue.delete(this.obj,"age")
                this.$delete(this.obj,"age")
            },
            addFn(){
                //由于 JavaScript 的限制，Vue 不能检测对象属性的添加或删除
                //触发不了响应式
                // this.obj.son="邱海峰"
                // Vue.set(this.obj,"son","邱海峰")
                this.$set(this.obj,"son","邱海峰")
            },
            updateFn(){
                this.obj.name = "武"
            }
        }
    })
</script>
</html>